﻿namespace RL
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.UI;

    internal static class utility
    {
        internal static void RegisterResources(List<string> files)
        {
            foreach (string str in files)
            {
                RegisterResources(str);
            }
        }

        internal static void RegisterResources(string[] files)
        {
            foreach (string str in files)
            {
                RegisterResources(str);
            }
        }

        public static void RegisterResources(string ResourceFile)
        {
            List<string> list = new List<string>();
            if (HttpContext.Current.Session[RL.AjaxPlaceHolder.PluginSessionkey] == null)
            {
                list = new List<string>();
            }
            else
            {
                list = (List<string>) HttpContext.Current.Session[RL.AjaxPlaceHolder.PluginSessionkey];
            }
            bool flag = false;
            foreach (string str in list)
            {
                if (str.ToLower() == ResourceFile.ToLower())
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                list.Add(ResourceFile);
                HttpContext.Current.Session[RL.AjaxPlaceHolder.PluginSessionkey] = list;
            }
        }

        internal static void sbAppp(StringBuilder sb, string text)
        {
            sb.Append(" " + text + " ");
        }

        public static RL.AjaxPlaceHolder SearchAjaxPlaceHolder(Control root)
        {
            if (root is RL.AjaxPlaceHolder)
            {
                return (RL.AjaxPlaceHolder) root;
            }
            foreach (Control control in root.Controls)
            {
                Control control2 = SearchAjaxPlaceHolder(control);
                if (control2 != null)
                {
                    return (RL.AjaxPlaceHolder) control2;
                }
            }
            return null;
        }

        public static Control SearchControl(Control root, string id)
        {
            if (root.ID == id)
            {
                return root;
            }
            foreach (Control control in root.Controls)
            {
                Control control2 = SearchControl(control, id);
                if (control2 != null)
                {
                    return control2;
                }
            }
            return null;
        }

        public static Control SearchControlByType(Control root, Type type)
        {
            if (root.GetType() == type)
            {
                return root;
            }
            foreach (Control control in root.Controls)
            {
                Control control2 = SearchControlByType(control, type);
                if (control2 != null)
                {
                    return control2;
                }
            }
            return null;
        }

        internal static string terminater(bool terminate)
        {
            return (terminate ? ";\r\n                " : string.Empty);
        }
    }
}

